package com.bw.day03.adapter

import android.graphics.Paint
import android.widget.TextView
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.base.net.entity.CateEntityItem
import com.bw.base.net.entity.Child
import com.bw.base.net.entity.Goods
import com.bw.day03.R
import com.bw.day03.util.GlideUtlis
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class TwoAdapter: BaseQuickAdapter<CateEntityItem, BaseViewHolder>(R.layout.item_two) {
    var selectId=534
    override fun convert(
        holder: BaseViewHolder,
        item: CateEntityItem
    ) {
        holder.setText(R.id.two_tv,"------${item.name}------")
        val rv = holder.getView<RecyclerView>(R.id.twp_rv)
        val twoChildAdapter = TwoChildAdapter()
        twoChildAdapter.data.addAll(item.child)
        rv.adapter = twoChildAdapter
        rv.layoutManager = GridLayoutManager(context,3)
        val rv2=holder.getView<RecyclerView>(R.id.rv_goods)
        val goodsAdapter = GoodsAdapter()
        rv2.adapter = goodsAdapter
        rv2.layoutManager = GridLayoutManager(context,2)
    }

}
class TwoChildAdapter:BaseQuickAdapter<Child,BaseViewHolder>(R.layout.item_twochid) {

        override fun convert(
        holder: BaseViewHolder,
        item: Child
    ) {
        holder.setText(R.id.child_tv,item.name)
        GlideUtlis.loadNormal(context,item.extra,holder.getView(R.id.child_iv))
        holder.itemView.setOnClickListener {
           ARouter.getInstance().build("/app/CateXqActivity").withInt("cid",item.id).withString("cname",item.name).navigation()
            val id=item.id


        }
    }

}


